package com.sailfish.springbootdemo.dao.db5;

import com.sailfish.springbootdemo.common.DB5TableName;
import com.sailfish.springbootdemo.common.DB7TableName;
import com.sailfish.springbootdemo.pojo.db5.PdmNewPartApplication;
import com.sailfish.springbootdemo.pojo.db7.TbDataDictionary;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

public interface PdmNewPartApplicationDao {

    @Select("<script> " +
            "select \n" +
            "*" +
            " from " + DB5TableName.PDM_NEWPART_APPLICATION +
            " where 1=1 and EDA_YZX_Last_SPR is not null and EDA_YZX_Last_Time >= '2025-08-01' " +
            "<if test='PdmNewPartApplication.s1partnumber != null and PdmNewPartApplication.s1partnumber!=\"\"'>" +
            " and s1partnumber = #{PdmNewPartApplication.s1partnumber}" +
            "</if>" +
            "<if test='PdmNewPartApplication.DocumentName != null and PdmNewPartApplication.DocumentName!=\"\"'>" +
            " and DocumentName = #{PdmNewPartApplication.DocumentName}" +
            "</if>" +
            " order by DocumentName asc" +
            "</script>")
    List<PdmNewPartApplication> getPdmNewPartApplicationList(@Param("PdmNewPartApplication") PdmNewPartApplication pdmNewPartApplication);

    @Select("<script> " +
            "select \n" +
            "*" +
            " from " + DB5TableName.PDM_NEWPART_APPLICATION +
            " where 1=1 and EDA_YZX_Last_SPR is not null" +
            " <if test='startTime != null'>" +
            "   AND EDA_YZX_Last_Time &gt;= #{startTime}" +
            " </if>" +
            " <if test='endTime != null'>" +
            "   AND EDA_YZX_Last_Time &lt;= #{endTime}" +
            " </if>" +
            "<if test='PdmNewPartApplication.s1partnumber != null and PdmNewPartApplication.s1partnumber!=\"\"'>" +
            " and s1partnumber = #{PdmNewPartApplication.s1partnumber}" +
            "</if>" +
            "<if test='PdmNewPartApplication.DocumentName != null and PdmNewPartApplication.DocumentName!=\"\"'>" +
            " and DocumentName = #{PdmNewPartApplication.DocumentName}" +
            "</if>" +
            " order by DocumentName asc" +
            "</script>")
    List<PdmNewPartApplication> getPdmNewPartApplicationList2(@Param("PdmNewPartApplication") PdmNewPartApplication pdmNewPartApplication,
                                                              @Param("startTime") Date startTime,
                                                              @Param("endTime") Date endTime);

}
